"""
Http Request
"""
from com.data.extract import HttpMethodEnum


class HttpRequest:
    def __init__(self, url="", method=HttpMethodEnum.HttpMethodEnum.GET, params={}, request_header={}):
        assert url != "", "url 不能为空"
        assert isinstance(method, HttpMethodEnum.HttpMethodEnum)
        self.url = url
        self.method = method
        self.params = params
        if request_header is None or request_header.__len__() == 0:
            request_header = {
              'Accept': 'application/json, text/javascript,*/*; q = 0.01',
              'Accept-Encoding': 'gzip, deflate',
              'Accept-Language': 'zh-CN, zh;q = 0.9',
              'Connection': 'keep-alive',
              'Host': 'data.stats.gov.cn',
              'Referer': 'http://data.stats.gov.cn/easyquery.htm?',
              'User-Agent': 'Mozilla / 5.0(X11;Linux x86_64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
              'X-Requested-With': 'XMLHttpRequest'
            }
        self.request_header = request_header
        self.cookie = {}

